package com.dao.impl;


import com.dao.BaseDao;
import com.dao.UserDao;
import com.pojo.User;

import java.util.List;

/**
 * @author zxl
 * @create :2022/9/28
 */
//dao实现类  实现dao接口中的抽象方法 具体实现功能
public abstract class UserDaoImpl extends BaseDao implements UserDao {
    @Override
    public User selectByUserNameAndPassWord(User user) {
        //通过sql调用数据操作了
        //书写sql语句
        String sql="select * from users where username = ? and password = ?";

        return selectForOne(User.class,sql,user.getUsername(),user.getPassword());
    }

    @Override
    public int insertUser(User user) {
        String sql ="insert into users(username,password) values(?,?)";
        return update(sql,user.getUsername(),user.getPassword());
    }

    @Override
    public List<User> selectByAll() {
        return null;
    }

    @Override
    public User selectByName(String username) {
        String sql="select * from users where username=?";
        return selectForOne(User.class,sql,username);
    }
}
